package org.xb.FactoryMethod;

import java.util.Scanner;

/**
 * @Author
 * @Description
 * @Date created in 15:21 2023/11/29
 */
public class Calculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入数字1");
        String number1 = scanner.nextLine();
        System.out.println("请选择运算符号（+、-、*、/）：");
        String operate = scanner.nextLine();
        IOperate iOperate = OperateFactory.getOperate(operate);
        if (iOperate == null){
            throw new RuntimeException("请检查你的计算符号");
        }
        System.out.println("请输入数字1");
        String number2 = scanner.nextLine();
        Double result = iOperate.operate(Double.parseDouble(number1), Double.parseDouble(number2));
        System.out.println("结果是 " + result);
    }
}
